package com.lightjet.macross.base.awf.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.lightjet.macross.common.util.FormatUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.activiti.engine.repository.Model;

/**
 * @author : lijia
 * @version : 1.0 2019-04-30 15:56
 * description : 流程模型的数据传输对象
 */
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class ProcModelDTO {

    private String id;
    private String metaInfo;
    private String name;
    private String key;
    private String createtime;
    private String deploymentId;
    private String lastupdatetime;
    private String category;

    public ProcModelDTO(Model m)
    {
        this.id = m.getId();
        this.metaInfo = m.getMetaInfo();
        this.name = m.getName();
        this.key = m.getKey();
        this.createtime = FormatUtil.GetDateTimeStr(m.getCreateTime());
        this.deploymentId = m.getDeploymentId();
        this.lastupdatetime = FormatUtil.GetDateTimeStr(m.getLastUpdateTime());
        this.category = m.getCategory();
    }

    @JsonIgnore
    public static ProcModelDTO FromProcessInstance(Model m)
    {
        return new ProcModelDTO(m.getId(),m.getMetaInfo(),m.getName(),m.getKey(), FormatUtil.GetDateTimeStr(m.getCreateTime()),m.getDeploymentId(),FormatUtil.GetDateTimeStr(m.getLastUpdateTime()),m.getCategory());
    }

}
